package service;

import java.sql.SQLException;
import java.util.List;

import dao.DoctorDaoImpl;
import domain.Doctor;
import domain.Owner;
import domain.Pet;

public class DoctorServiceImpl {
	//创建DoctorDaoImpl对象
	DoctorDaoImpl doctorDao = new DoctorDaoImpl();
	
	/**
	 * 查询所有宠物医生信息
	 * @return
	 */
	public List<Doctor> findAllDoctors(){
		try {
			return doctorDao.findAllDoctors();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 添加一条宠物医生信息
	 * @param doctor
	 */
	public void addDoctor(Doctor doctor){
		try {
			doctorDao.addDoctor(doctor);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 通过医生id查找宠物医生信息
	 * @param id
	 * @return
	 */
	public Doctor findDoctorById(String doctorId) {
		try {
			return doctorDao.findDoctorById(doctorId);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 更新宠物医生信息
	 * @param doctor
	 */
	public void updateDoctor(Doctor doctor) {
		try {
			doctorDao.updateDoctor(doctor);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public List<Pet> findPetsByDoctorId(String doctorId) {
		// TODO Auto-generated method stub
		try {
			return doctorDao.findPetsByDoctorId(doctorId);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 通过doctorId删除医生信息
	 * @param id
	 * @return
	 */
	public void deleteDoctorById(String doctorId) {
		try {
			doctorDao.deleteDoctorById(doctorId);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	/**
	 * 
	 * @param doctorId
	 * @param doctorName
	 * @param expertise
	 * @param doctorPhone
	 * @param credentials
	 * @return
	 */
	public List<Doctor> findDoctorByConditions(String doctorId,
			String doctorName, String expertise, String doctorPhone,
			String credentials) {
		try {
			return doctorDao.findDoctorByConditions(doctorId, doctorName, expertise, credentials, doctorPhone);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	
	
}
